import axios from 'axios'
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// import axios from 'axios'
export default new Vuex.Store({
    state: {
        list : [],  //存放所有数据
    },
    mutations: {
        // 改变list数据
        setlist(state,payload){
            state.list = payload
        }
    },
    actions: {
        // 请求数据接口
        getlist({ commit }){
            axios.post('/list').then(res => {
                commit('setlist',res.data)
            })
        }
    },
    modules: {
    }
})
